package com.lanou.lenanapp.factory;


import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.lanou.lenanapp.fragment.ImageCollectFragment;
import com.lanou.lenanapp.fragment.JokeCollectFragment;


/**
 * Created by dllo on 15/11/5.
 */
public class FragmentFactory {

    private static SparseArray<Fragment> fragmentMap = new SparseArray<Fragment>();

    public static Fragment creatFragment(int position){
        Fragment f = fragmentMap.get(position);
        if (f == null){
            switch (position){
                case 0:
                    f = new JokeCollectFragment();
                    break;
                case 1:
                    f = new ImageCollectFragment();
                    break;
            }
            fragmentMap.put(position, f);
        }
        return  f;
    }
}
